package com.lucenly.card.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.lucenly.card.R;

public class HomeDkDialog extends Dialog{
    public HomeDkDialog(@NonNull Context context) {
        super(context, R.style.alert_dialog);
        setContentView(R.layout.dialog_home_dk);
        ImageView iv_guanbi = findViewById(R.id.iv_guanbi);
        RecyclerView recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        iv_guanbi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        initView(context);
    }

    private void initView(Context context) {
        LinearLayout lLayout_bg = (LinearLayout) findViewById(R.id.lLayout_bg);
        WindowManager windowManager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        setCanceledOnTouchOutside(false);
        // 调整dialog背景大小
        lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (display
                .getWidth() * 0.8), LinearLayout.LayoutParams.WRAP_CONTENT));
        setCanceledOnTouchOutside(true);
    }
}
